home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / form1.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-07-15  |  22.3 KB  |  709 lines

  1. //******************************************************************'
  2. //*                                                                *'
  3. //*                      TurboCAD for Windows                      *'
  4. //*                   Copyright (c) 1993 - 2004                    *'
  5. //*             International Microcomputer Software, Inc.         *'
  6. //*                            (IMSI)                              *'
  7. //*                      All rights reserved.                      *'
  8. //*                                                                *'
  9. //******************************************************************'
  10. #pragma once
  11. //#include "StdAfx.h"
  12. //#include "TcEngine.h"
  13. //using namespace Interop::IMSIGX ;
  14. #include "tcengine.h"
  15. enum ActiveTool
  16. {
  17.     iSelectTool = 0,
  18.     iAddLineSingleTool = 1,
  19.     iAddCircleCenterAndPoint = 2
  20. };
  21.  
  22. namespace TcGeometryVC_Net
  23. {
  24.     using namespace System;
  25.     using namespace System::ComponentModel;
  26.     using namespace System::Collections;
  27.     using namespace System::Windows::Forms;
  28.     using namespace System::Data;
  29.     using namespace System::Drawing;
  30.  
  31.     /// <summary> 
  32.     /// Summary for Form1
  33.     ///
  34.     /// WARNING: If you change the name of this class, you will need to change the 
  35.     ///          'Resource File Name' property for the managed resource compiler tool 
  36.     ///          associated with all .resx files this class depends on.  Otherwise,
  37.     ///          the designers will not be able to interact properly with localized
  38.     ///          resources associated with this form.
  39.     /// </summary>
  40.     public __gc class Form1 : public System::Windows::Forms::Form
  41.     {    
  42.     public:
  43.         Form1(void)
  44.         {
  45.             InitializeComponent();
  46.             m_tcEngine = new TcEngine();
  47.             pGraphics = picView->CreateGraphics ();
  48.             pGraphics->CompositingQuality  = System::Drawing::Drawing2D::CompositingQuality::HighQuality  ;
  49.             pPen = new Pen(System::Drawing::Color::Blue ,1);
  50.             EnableButtons(false);
  51.             firstPointX = firstPointY = -1;
  52.             previousMoveX = previousMoveY = -1;
  53.             m_bDrag = false;
  54.             m_iActiveTool = iSelectTool;
  55.             sTitle = "TCGeometry sample application !";
  56.             this->Text = sTitle;
  57.         }
  58.  
  59.     protected:
  60.         void Dispose(Boolean disposing)
  61.         {
  62.             if (disposing && components)
  63.             {
  64.                 components->Dispose();
  65.             }
  66.             __super::Dispose(disposing);
  67.         }
  68.     private: System::Windows::Forms::PictureBox *  picView;
  69.     private: System::Windows::Forms::StatusBar *  statusBar1;
  70.     private: System::Windows::Forms::GroupBox *  groupBox1;
  71.     private: System::Windows::Forms::GroupBox *  groupBox2;
  72.     private: System::Windows::Forms::Button *  cmCreateTCApp;
  73.     private: System::Windows::Forms::Button *  cmNewDrawing;
  74.     private: System::Windows::Forms::Button *  cmCloseDrawing;
  75.     private: System::Windows::Forms::Button *  cmZoomIn;
  76.     private: System::Windows::Forms::Button *  cmZoomOut;
  77.     private: System::Windows::Forms::Button *  cmZoomExtents;
  78.     private: System::Windows::Forms::Button *  cmCreateLine;
  79.     private: System::Windows::Forms::Button *  cmCreateCircle;
  80.     private: System::Windows::Forms::Button *  cmSelect;
  81.     public private: System::Windows::Forms::Label *  label3;
  82.     public private: System::Windows::Forms::Label *  label2;
  83.     public private: System::Windows::Forms::Label *  label1;
  84.     public private: System::Windows::Forms::TreeView *  propsPalette;
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.     private:
  94.         /// <summary>
  95.         /// Required designer variable.
  96.         /// </summary>
  97.         System::ComponentModel::Container * components;
  98.  
  99.         /// <summary>
  100.         /// Required method for Designer support - do not modify
  101.         /// the contents of this method with the code editor.
  102.         /// </summary>
  103.         void InitializeComponent(void)
  104.         {
  105.             this->picView = new System::Windows::Forms::PictureBox();
  106.             this->statusBar1 = new System::Windows::Forms::StatusBar();
  107.             this->groupBox1 = new System::Windows::Forms::GroupBox();
  108.             this->cmCreateTCApp = new System::Windows::Forms::Button();
  109.             this->groupBox2 = new System::Windows::Forms::GroupBox();
  110.             this->cmNewDrawing = new System::Windows::Forms::Button();
  111.             this->cmCloseDrawing = new System::Windows::Forms::Button();
  112.             this->cmZoomIn = new System::Windows::Forms::Button();
  113.             this->cmZoomOut = new System::Windows::Forms::Button();
  114.             this->cmZoomExtents = new System::Windows::Forms::Button();
  115.             this->cmCreateLine = new System::Windows::Forms::Button();
  116.             this->cmCreateCircle = new System::Windows::Forms::Button();
  117.             this->cmSelect = new System::Windows::Forms::Button();
  118.             this->label3 = new System::Windows::Forms::Label();
  119.             this->label2 = new System::Windows::Forms::Label();
  120.             this->label1 = new System::Windows::Forms::Label();
  121.             this->propsPalette = new System::Windows::Forms::TreeView();
  122.             this->groupBox1->SuspendLayout();
  123.             this->groupBox2->SuspendLayout();
  124.             this->SuspendLayout();
  125.             // 
  126.             // picView
  127.             // 
  128.             this->picView->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
  129.             this->picView->Location = System::Drawing::Point(0, 184);
  130.             this->picView->Name = S"picView";
  131.             this->picView->Size = System::Drawing::Size(624, 408);
  132.             this->picView->TabIndex = 0;
  133.             this->picView->TabStop = false;
  134.             this->picView->Click += new System::EventHandler(this, picView_Click);
  135.             this->picView->MouseMove += new System::Windows::Forms::MouseEventHandler(this, picView_MouseMove);
  136.             this->picView->MouseDown += new System::Windows::Forms::MouseEventHandler(this, picView_MouseDown);
  137.             // 
  138.             // statusBar1
  139.             // 
  140.             this->statusBar1->Location = System::Drawing::Point(0, 597);
  141.             this->statusBar1->Name = S"statusBar1";
  142.             this->statusBar1->Size = System::Drawing::Size(896, 16);
  143.             this->statusBar1->TabIndex = 1;
  144.             this->statusBar1->Text = S"statusBar1";
  145.             // 
  146.             // groupBox1
  147.             // 
  148.             this->groupBox1->Controls->Add(this->cmCreateTCApp);
  149.             this->groupBox1->Location = System::Drawing::Point(16, 8);
  150.             this->groupBox1->Name = S"groupBox1";
  151.             this->groupBox1->Size = System::Drawing::Size(208, 80);
  152.             this->groupBox1->TabIndex = 2;
  153.             this->groupBox1->TabStop = false;
  154.             this->groupBox1->Text = S"Application";
  155.             // 
  156.             // cmCreateTCApp
  157.             // 
  158.             this->cmCreateTCApp->Location = System::Drawing::Point(16, 32);
  159.             this->cmCreateTCApp->Name = S"cmCreateTCApp";
  160.             this->cmCreateTCApp->Size = System::Drawing::Size(80, 24);
  161.             this->cmCreateTCApp->TabIndex = 3;
  162.             this->cmCreateTCApp->Text = S"Create";
  163.             this->cmCreateTCApp->Click += new System::EventHandler(this, cmCreateTCApp_Click);
  164.             // 
  165.             // groupBox2
  166.             // 
  167.             this->groupBox2->Controls->Add(this->cmNewDrawing);
  168.             this->groupBox2->Controls->Add(this->cmCloseDrawing);
  169.             this->groupBox2->Location = System::Drawing::Point(248, 8);
  170.             this->groupBox2->Name = S"groupBox2";
  171.             this->groupBox2->Size = System::Drawing::Size(256, 80);
  172.             this->groupBox2->TabIndex = 2;
  173.             this->groupBox2->TabStop = false;
  174.             this->groupBox2->Text = S"Drawing";
  175.             // 
  176.             // cmNewDrawing
  177.             // 
  178.             this->cmNewDrawing->Location = System::Drawing::Point(16, 32);
  179.             this->cmNewDrawing->Name = S"cmNewDrawing";
  180.             this->cmNewDrawing->Size = System::Drawing::Size(80, 24);
  181.             this->cmNewDrawing->TabIndex = 3;
  182.             this->cmNewDrawing->Text = S"New";
  183.             this->cmNewDrawing->Click += new System::EventHandler(this, cmNewDrawing_Click);
  184.             // 
  185.             // cmCloseDrawing
  186.             // 
  187.             this->cmCloseDrawing->Location = System::Drawing::Point(160, 32);
  188.             this->cmCloseDrawing->Name = S"cmCloseDrawing";
  189.             this->cmCloseDrawing->Size = System::Drawing::Size(80, 24);
  190.             this->cmCloseDrawing->TabIndex = 3;
  191.             this->cmCloseDrawing->Text = S"Close";
  192.             this->cmCloseDrawing->Click += new System::EventHandler(this, cmCloseDrawing_Click);
  193.             // 
  194.             // cmZoomIn
  195.             // 
  196.             this->cmZoomIn->Location = System::Drawing::Point(16, 112);
  197.             this->cmZoomIn->Name = S"cmZoomIn";
  198.             this->cmZoomIn->Size = System::Drawing::Size(80, 24);
  199.             this->cmZoomIn->TabIndex = 4;
  200.             this->cmZoomIn->Text = S"Zoom In";
  201.             this->cmZoomIn->Click += new System::EventHandler(this, cmZoomIn_Click);
  202.             // 
  203.             // cmZoomOut
  204.             // 
  205.             this->cmZoomOut->Location = System::Drawing::Point(104, 112);
  206.             this->cmZoomOut->Name = S"cmZoomOut";
  207.             this->cmZoomOut->Size = System::Drawing::Size(80, 24);
  208.             this->cmZoomOut->TabIndex = 4;
  209.             this->cmZoomOut->Text = S"Zoom Out";
  210.             this->cmZoomOut->Click += new System::EventHandler(this, cmZoomOut_Click);
  211.             // 
  212.             // cmZoomExtents
  213.             // 
  214.             this->cmZoomExtents->Location = System::Drawing::Point(192, 112);
  215.             this->cmZoomExtents->Name = S"cmZoomExtents";
  216.             this->cmZoomExtents->Size = System::Drawing::Size(88, 24);
  217.             this->cmZoomExtents->TabIndex = 4;
  218.             this->cmZoomExtents->Text = S"Zoom Extents";
  219.             this->cmZoomExtents->Click += new System::EventHandler(this, cmZoomExtents_Click);
  220.             // 
  221.             // cmCreateLine
  222.             // 
  223.             this->cmCreateLine->Location = System::Drawing::Point(288, 112);
  224.             this->cmCreateLine->Name = S"cmCreateLine";
  225.             this->cmCreateLine->Size = System::Drawing::Size(80, 24);
  226.             this->cmCreateLine->TabIndex = 4;
  227.             this->cmCreateLine->Text = S"Add Line";
  228.             this->cmCreateLine->Click += new System::EventHandler(this, cmCreateLine_Click);
  229.             // 
  230.             // cmCreateCircle
  231.             // 
  232.             this->cmCreateCircle->Location = System::Drawing::Point(376, 112);
  233.             this->cmCreateCircle->Name = S"cmCreateCircle";
  234.             this->cmCreateCircle->Size = System::Drawing::Size(80, 24);
  235.             this->cmCreateCircle->TabIndex = 4;
  236.             this->cmCreateCircle->Text = S"Add Circle";
  237.             this->cmCreateCircle->Click += new System::EventHandler(this, cmCreateCircle_Click);
  238.             // 
  239.             // cmSelect
  240.             // 
  241.             this->cmSelect->Location = System::Drawing::Point(464, 112);
  242.             this->cmSelect->Name = S"cmSelect";
  243.             this->cmSelect->Size = System::Drawing::Size(80, 24);
  244.             this->cmSelect->TabIndex = 4;
  245.             this->cmSelect->Text = S"Select";
  246.             this->cmSelect->Click += new System::EventHandler(this, cmSelect_Click);
  247.             // 
  248.             // label3
  249.             // 
  250.             this->label3->Location = System::Drawing::Point(144, 152);
  251.             this->label3->Name = S"label3";
  252.             this->label3->Size = System::Drawing::Size(208, 23);
  253.             this->label3->TabIndex = 10;
  254.             // 
  255.             // label2
  256.             // 
  257.             this->label2->Location = System::Drawing::Point(16, 152);
  258.             this->label2->Name = S"label2";
  259.             this->label2->TabIndex = 9;
  260.             this->label2->Text = S"Active Tool :";
  261.             // 
  262.             // label1
  263.             // 
  264.             this->label1->Location = System::Drawing::Point(624, 152);
  265.             this->label1->Name = S"label1";
  266.             this->label1->Size = System::Drawing::Size(144, 24);
  267.             this->label1->TabIndex = 12;
  268.             this->label1->Text = S"Properties:";
  269.             // 
  270.             // propsPalette
  271.             // 
  272.             this->propsPalette->ImageIndex = -1;
  273.             this->propsPalette->Location = System::Drawing::Point(624, 184);
  274.             this->propsPalette->Name = S"propsPalette";
  275.             this->propsPalette->SelectedImageIndex = -1;
  276.             this->propsPalette->Size = System::Drawing::Size(264, 408);
  277.             this->propsPalette->TabIndex = 11;
  278.             // 
  279.             // Form1
  280.             // 
  281.             this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
  282.             this->ClientSize = System::Drawing::Size(896, 613);
  283.             this->Controls->Add(this->label1);
  284.             this->Controls->Add(this->propsPalette);
  285.             this->Controls->Add(this->label3);
  286.             this->Controls->Add(this->label2);
  287.             this->Controls->Add(this->groupBox1);
  288.             this->Controls->Add(this->statusBar1);
  289.             this->Controls->Add(this->picView);
  290.             this->Controls->Add(this->groupBox2);
  291.             this->Controls->Add(this->cmZoomIn);
  292.             this->Controls->Add(this->cmZoomOut);
  293.             this->Controls->Add(this->cmZoomExtents);
  294.             this->Controls->Add(this->cmCreateLine);
  295.             this->Controls->Add(this->cmCreateCircle);
  296.             this->Controls->Add(this->cmSelect);
  297.             this->Name = S"Form1";
  298.             this->Text = S"Form1";
  299.             this->groupBox1->ResumeLayout(false);
  300.             this->groupBox2->ResumeLayout(false);
  301.             this->ResumeLayout(false);
  302.  
  303.         }    
  304.  
  305.     private: System::Void cmTest_Click(System::Object *  sender, System::EventArgs *  e)
  306.              {
  307.              }
  308.  
  309. //public:
  310. //    IApplicatin* ptcApp;
  311. private: System::Void cmZoomIn_Click(System::Object *  sender, System::EventArgs *  e)
  312.          {
  313.             m_tcEngine->Zoom (0.8);
  314.             picView->Refresh ();
  315.             m_tcEngine->m_gxView->Refresh ();
  316.          }
  317.  
  318. public:
  319.     TcEngine* m_tcEngine;
  320.     Color m_BackgroundColor;
  321.     System::Drawing::Pen* pPen;
  322.     System::Drawing::Pen* pPenBackground;
  323.     int firstPointX;
  324.     int firstPointY;
  325.     int previousMoveX;
  326.     int previousMoveY;
  327.     System::String* sTitle;
  328.     bool m_bDrag;
  329.     ActiveTool m_iActiveTool;
  330.     System::Drawing::Graphics* pGraphics;
  331.     
  332. private: System::Void cmNewDrawing_Click(System::Object *  sender, System::EventArgs *  e)
  333.          {
  334.  
  335.              System::String* s;
  336.             m_tcEngine->CreategxDrawing ();
  337. //            System::Object*  varVal;
  338.             long lcolor;
  339.             lcolor = RGB(255,255,255);
  340.             m_BackgroundColor = picView->BackColor;
  341.             picView->BackColor = System::Drawing::ColorTranslator::FromWin32 (lcolor);
  342.             pPenBackground = new Pen (picView->BackColor  ,1);
  343.             m_tcEngine->CreategxView ((int)picView->Handle);
  344.             m_tcEngine->m_gxView->ZoomToExtents ();
  345.             EnableButtons(true);
  346.             s = sTitle;
  347.             s = s->Insert (s->Length,"--------");
  348.             s = s->Insert (s->Length,m_tcEngine->m_gxDrawing->get_Name ());
  349.             this->Text = s;
  350.          }
  351.  
  352.  
  353. private: System::Void cmCreateLine_Click(System::Object *  sender, System::EventArgs *  e)
  354.          {
  355.              m_tcEngine->m_gxDrawing->Graphics->Unselect ();
  356.             m_tcEngine->m_gxView->Refresh ();
  357.             m_iActiveTool = iAddLineSingleTool;
  358.             UpdatePrompt();
  359.          }
  360.  
  361. public:
  362.  
  363.     void UpdatePrompt(void)
  364.     {
  365.             statusBar1->Text = "";
  366.             switch (m_iActiveTool)
  367.             {
  368.                 case iSelectTool :
  369.                 {
  370.                     statusBar1->Text = "Select Object";
  371.                     label3->Text = "Select Tool";
  372.                 }
  373.                 break;
  374.                 case iAddLineSingleTool:
  375.                 {
  376.                     if (m_bDrag == false)
  377.                     {
  378.                         statusBar1->Text = "Define the start point of the line";
  379.                         label3->Text = "Add Single Line";
  380.                     }
  381.                     else
  382.                     {
  383.                         statusBar1->Text = "Define the end point of the line";
  384.                         label3->Text = "Add Single Line";
  385.                     }
  386.                 }
  387.                 break;
  388.                 case iAddCircleCenterAndPoint:
  389.                 {
  390.                     if (m_bDrag == false)
  391.                     {
  392.                         statusBar1->Text = "Define the center point of the circle";
  393.                         label3->Text = "Add Circle Center and Point";
  394.                     }
  395.                     else
  396.                     {
  397.                         statusBar1->Text = "Define a second point of the circle's circumferences";
  398.                         label3->Text = "Add Circle Center and Point";
  399.                     }
  400.                 
  401.                 }
  402.                     break;
  403.  
  404.             }
  405.  
  406.     }
  407.  
  408.     void EnableButtons(bool bVal)
  409.     {
  410.         cmCloseDrawing->Enabled = bVal;
  411.         cmZoomIn->Enabled = bVal;
  412.         cmZoomOut->Enabled = bVal;
  413.         cmZoomExtents->Enabled = bVal;
  414.         cmCreateLine->Enabled = bVal;
  415.         cmCreateCircle->Enabled = bVal;
  416.         cmSelect->Enabled = bVal;
  417.         m_iActiveTool = iSelectTool;
  418.         UpdatePrompt();
  419.     }
  420. private: System::Void cmZoomOut_Click(System::Object *  sender, System::EventArgs *  e)
  421.          {
  422.             m_tcEngine->Zoom (1.2);
  423.             picView->Refresh ();
  424.             m_tcEngine->m_gxView->Refresh ();
  425.          }
  426.  
  427. private: System::Void cmZoomExtents_Click(System::Object *  sender, System::EventArgs *  e)
  428.          {
  429.             if (m_tcEngine->m_gxView != NULL)
  430.             {
  431.                 picView->Refresh ();
  432.                 m_tcEngine->m_gxView->ZoomToExtents ();
  433.             }
  434.          }
  435.  
  436. private: System::Void cmCreateCircle_Click(System::Object *  sender, System::EventArgs *  e)
  437.          {
  438.             m_tcEngine->m_gxDrawing->Graphics->Unselect ();
  439.             m_tcEngine->m_gxView->Refresh ();
  440.             m_iActiveTool = iAddCircleCenterAndPoint;
  441.             UpdatePrompt();
  442.  
  443.          }
  444.  
  445. private: System::Void cmSelect_Click(System::Object *  sender, System::EventArgs *  e)
  446.          {
  447.             statusBar1->Text = "Select object";
  448.             m_iActiveTool = iSelectTool ;
  449.             UpdatePrompt();
  450.             FillPropertiesPalette(NULL);
  451.          }
  452.  
  453. public:
  454.  
  455.     void FillPropertiesPalette(IGraphic* pGraphic)
  456.     {
  457.             ClearPropertiesPalette();
  458.             if (pGraphic == NULL)
  459.                 return;
  460.             // fill common info
  461.             TreeNode *pRootNode;
  462.             TreeNode *pchildNode;
  463.             
  464.             Vertices*  gxVertices;
  465.             IVertex*    gxVertex;
  466.             System::Object* var;
  467.             double vardblVal;
  468.             double radius;
  469.             double xCenter, yCenter, X, Y, Z;
  470.             int id;
  471.             CString grType;
  472.             CString s;
  473.             vardblVal = 0;
  474.             pRootNode = propsPalette->Nodes->Add ("General");
  475.             id = pGraphic->get_ID ();
  476.             s = "GraphicID = ";
  477.             s = s + id.ToString ();
  478.             pRootNode->Nodes->Add (s );
  479.             s.Empty ();
  480.             s = "Type = ";
  481.             grType = pGraphic->get_Type();
  482.             s = s + grType;// + grType..ToString ();
  483.             pRootNode->Nodes->Add (s);
  484.             pRootNode = propsPalette->Nodes->Add ("Geometry Information");
  485.             gxVertices = pGraphic->Vertices;
  486.             
  487.             if (pGraphic->TypeByValue == 2  ) // imsiArc
  488.             {
  489.  
  490.                 pchildNode = pRootNode->Nodes->Add ("Center");
  491.                 //var = __try_cast<System::Object*>(Convert::ChangeType(__box(0), __typeof(System::Object )));
  492.                 var = __box(0);
  493.                 gxVertex = gxVertices->get_Item(&var);
  494.                 xCenter = gxVertex->X;
  495.                 yCenter = gxVertex->Y;
  496.                 vardblVal = gxVertex->X ;
  497.                 s.Empty ();
  498.                 s = vardblVal.ToString();
  499.                 pchildNode->Nodes->Add ("X = " + s);
  500.                 vardblVal = gxVertex->Y;
  501.                 s.Empty ();
  502.                 s = vardblVal.ToString();
  503.                 pchildNode->Nodes->Add ("Y = " + s);
  504.                 pchildNode->Nodes->Add ("Z = 0");
  505.                 
  506.                 //var = __try_cast<System::Object*>(Convert::ChangeType(__box(1), __typeof(System::Object )));
  507.                 var = __box(1);
  508.                 gxVertex = gxVertices->get_Item(&var);
  509.                 X = gxVertex->X;
  510.                 Y = gxVertex->Y;
  511.                 radius = (float)System::Math::Sqrt ((xCenter - X)*(xCenter - X) + (yCenter - Y) * (yCenter - Y));
  512.                 s.Empty() ;
  513.                 s = "Radius ";
  514.                 s = s + radius.ToString ();
  515.                 pchildNode = pRootNode->Nodes->Add (s);
  516.             }
  517.             else if (pGraphic->get_TypeByValue () == imsiPolyline )
  518.             {
  519.                 int n, i;
  520.                 n = gxVertices->get_Count ();
  521.                 pRootNode = pRootNode->Nodes->Add ("Vertices");
  522.                 for (i = 0; i < n; i++)
  523.                 {
  524.                     //var = __try_cast<System::Object*>(Convert::ChangeType(__box(i), __typeof(System::Object )));
  525.                     var = __box(i);
  526.                     gxVertex = gxVertices->get_Item(&var);
  527.                     s.Empty ();
  528.                     s = "V ";
  529.                     s = s + var->ToString ();
  530.                     pchildNode = pRootNode->Nodes->Add (s);
  531.                     X = gxVertex->X;
  532.                     Y = gxVertex->Y;
  533.                     Z = gxVertex->Z;
  534.                     s.Empty();
  535.                     s = X.ToString ();
  536.                     pchildNode->Nodes->Add ("X = " + s);
  537.                     s.Empty();
  538.                     s = Y.ToString ();
  539.                     pchildNode->Nodes->Add ("Y = " + s);
  540.                     s.Empty();
  541.                     s = Z.ToString ();
  542.                     pchildNode->Nodes->Add ("Z = " + s);
  543.                 }
  544.  
  545.             }
  546.             pGraphic->Drawing->Graphics->Unselect ();
  547.             pGraphic->Selected = true;
  548.             m_tcEngine->m_gxView->Refresh ();
  549.             propsPalette->ExpandAll ();                        
  550.  
  551.     }
  552.  
  553.     void ClearPropertiesPalette(void)
  554.     {
  555.         propsPalette->Nodes->Clear ();
  556.     }
  557. private: System::Void picView_Click(System::Object *  sender, System::EventArgs *  e)
  558.          {
  559.  
  560.          }
  561. private: System::Void picView_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
  562.          {
  563.             IGraphic* gxGraphic;
  564.             int mouseX = e->X;
  565.             int mouseY = e->Y;
  566.             if (m_tcEngine->m_gxView == NULL)
  567.                 return;
  568.             if (e->Button == System::Windows::Forms ::MouseButtons ::Left)
  569.             {
  570.                 if (m_iActiveTool != iSelectTool )
  571.                 {
  572.                     // if firstPointX nad firstPointY equal -1 it means that tool just started and 
  573.                     // is in first click mode
  574.                     if (firstPointY == -1 && firstPointX == -1)
  575.                     {
  576.                         // store coordinates of first click
  577.                         firstPointX = mouseX;
  578.                         firstPointY = mouseY;
  579.                         // switch to second click mode
  580.                         m_bDrag = true;
  581.                         UpdatePrompt();
  582.                         return;
  583.                     }
  584.                 }
  585.  
  586.                 switch (m_iActiveTool)
  587.                 {
  588.                     case iSelectTool :
  589.                     {
  590.                         m_tcEngine->m_gxDrawing->Graphics->Unselect ();
  591.                         IGraphic* gxSelectedGraphic = m_tcEngine->SelectGraphic(mouseX, mouseY);
  592.                         FillPropertiesPalette(gxSelectedGraphic);
  593.                         m_tcEngine->m_gxView->Refresh ();
  594.                     }
  595.                     break;
  596.  
  597.                     case iAddLineSingleTool  :
  598.                     {
  599.                         gxGraphic = m_tcEngine->AddLineSingle (firstPointX,firstPointY, mouseX, mouseY);
  600.                         m_bDrag = false;
  601.                         firstPointX = -1;
  602.                         firstPointY = -1;
  603.                         previousMoveX = -1;
  604.                         previousMoveY = -1;
  605.                     }
  606.                     break;
  607.  
  608.                     case iAddCircleCenterAndPoint :
  609.                     {
  610.                         gxGraphic = m_tcEngine->AddCircleCenterAndPoint (firstPointX,firstPointY, mouseX, mouseY);
  611.                         m_bDrag = false;
  612.                         firstPointX = -1;
  613.                         firstPointY = -1;
  614.                         previousMoveX = -1;
  615.                         previousMoveY = -1;
  616.                     }    
  617.                     break;
  618.  
  619.                 
  620.                 
  621.                 }
  622.                 picView->Refresh ();
  623.                 m_tcEngine->m_gxView->Refresh ();
  624.                 UpdatePrompt();
  625.                 return;
  626.             }
  627.  
  628.          }
  629.  
  630. private: System::Void picView_MouseMove(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)
  631.          {
  632.             // Update the mouse path that is drawn onto the Panel.
  633.             UpdatePrompt();
  634.             if (!m_bDrag)
  635.                 return;
  636.  
  637.             int mouseX = e->X;
  638.             int mouseY = e->Y;
  639.             int r = 0;
  640.  
  641.             switch (m_iActiveTool)
  642.             {
  643.                 case iAddLineSingleTool:
  644.                 {
  645.                     if (m_bDrag == true)
  646.                     {
  647.                         // draw previous state of line with background color to hide it
  648.                         pGraphics->DrawLine (pPenBackground,firstPointX,firstPointY,previousMoveX, previousMoveY);
  649.                         // draw current staet of line
  650.                         pGraphics->DrawLine (pPen,firstPointX,firstPointY,mouseX, mouseY);
  651.                     }
  652.                 }
  653.                     break;
  654.                 case iAddCircleCenterAndPoint:
  655.                 {
  656.                     // calculate radius for previous state of the circle
  657.                     r = (float)System::Math::Sqrt ((firstPointX - previousMoveX)*(firstPointX - previousMoveX) + (firstPointY - previousMoveY) * (firstPointY - previousMoveY));
  658.                     if (r != 0)
  659.                     {
  660.                         // hide previous state of circle by draw it with background color
  661.                         pGraphics->DrawArc (pPenBackground, firstPointX - r, firstPointY - r , 2*r, 2*r, 0, 360);
  662.                     }
  663.                     // calculate radius of circle for current state
  664.                     r = (float)System::Math::Sqrt ((firstPointX - mouseX)*(firstPointX - mouseX) + (firstPointY - mouseY) * (firstPointY - mouseY));
  665.                     if (r != 0)
  666.                     {
  667.                         // draw current state of the circle
  668.                         pGraphics->DrawArc (pPen, firstPointX - r, firstPointY - r , 2*r, 2*r, 0, 360);
  669.                     }
  670.                 }
  671.                     break;
  672.             }
  673.             previousMoveX = mouseX;
  674.             previousMoveY = mouseY;
  675.  
  676.             if (m_tcEngine->m_gxView != NULL)
  677.             {
  678.                 m_tcEngine->m_gxView->Refresh ();
  679.             }
  680.             return;
  681.  
  682.          }
  683.  
  684. private: System::Void cmCloseDrawing_Click(System::Object *  sender, System::EventArgs *  e)
  685.          {
  686.              System::Object* missing = NULL;
  687.             m_bDrag = false;
  688.             pPenBackground->Dispose ();
  689.             m_tcEngine->m_gxDrawing->Close (&missing, &missing, &missing);
  690.             m_tcEngine->m_gxDrawing = NULL;
  691.             m_tcEngine->m_gxView = NULL;
  692.             EnableButtons(false);
  693.             this->Text = sTitle;
  694.             picView->BackColor = m_BackgroundColor;
  695.             picView->Refresh ();
  696.             statusBar1->Text = "";
  697.  
  698.          }
  699.  
  700. private: System::Void cmCreateTCApp_Click(System::Object *  sender, System::EventArgs *  e)
  701.          {
  702.             m_tcEngine->CreategxApp ();
  703.          }
  704.  
  705. };
  706. }
  707.  
  708.  
  709.